﻿using System.Windows.Media;
using DimensionsHelper.Common.Contracts.Excel;

namespace DimensionsHelper.Client;

internal static class Extensions
{
    public static Color ToColor(this System.Drawing.Color color)
    {
        return Color.FromArgb(
            color.A,
            color.R,
            color.G,
            color.B);
    }


    public static System.Drawing.Color ToColor(this Color color)
    {
        if (color.A == 0)
        {
            return System.Drawing.Color.Empty;
        }

        return System.Drawing.Color.FromArgb(
            color.A,
            color.R,
            color.G,
            color.B);
    }


    public static Color ToColor(this ExcelStyleColor color)
    {
        return color == ExcelStyleColor.Empty ? Colors.Transparent : Color.FromRgb(color.R, color.G, color.B);
    }


    public static ExcelStyleColor ToExcelStyleColor(this Color color)
    {
        if (color.A == 0)
        {
            return ExcelStyleColor.Empty;
        }

        return new ExcelStyleColor(color.R, color.G, color.B);
    }

}
